package com.tlgen.service;

import com.tlgen.mapper.AffairMapper;
import com.tlgen.model.Affair;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * @author: tlgen
 * @Discription:
 */
@Service
public class AffairService {

    @Autowired
    AffairMapper affairMapper;

    public Integer deleteAffairByIds(Integer[] ids) {
        return affairMapper.deleteAffairByIds(ids);
    }

    public Integer deleteAffairById(Integer id) {
        return affairMapper.deleteByPrimaryKey(id);
    }

    public Integer updateAffair(Affair Affair) {
        return affairMapper.updateByPrimaryKeySelective(Affair);
    }

    public Integer addAffair(Affair Affair) {
        Affair.setCreateDate(new Date());
        Affair.setEnabled(true);
        return affairMapper.insertSelective(Affair);
    }

    public List<Affair> getAllAffairs() {
        return affairMapper.getAllAffairs();
    }
}
